Skip to content

Dev0#8

Merged
iamserda merged 4 commits into
mainfrom
dev0
Feb 12, 2026
Merged

Dev0#8
iamserda merged 4 commits into
mainfrom
dev0

Conversation

@iamserda
Copy link
Copy Markdown
Owner

This pull request introduces a major refactor to the backend of the Shorties App, migrating persistent storage from in-memory dictionaries to a SQL database using SQLModel. It also streamlines the API models and endpoints, improves error handling, and updates the Makefile for better developer experience. The most important changes are grouped below:

Database Integration and Models

  • Introduced a new db_engine_factory function in db.py to create and manage the SQLModel database engine, with error handling and support for environment-based configuration. (src/app/db/db.py)
  • Added a new ShortiLink SQLModel for storing short links in the database, replacing the previous in-memory dictionary. (src/app/db/models/models.py)

API Refactor and Persistence

  • Refactored all API endpoints in main.py to use the database via SQLModel sessions, including:
    • display_all now fetches all short links from the database.
    • get_url fetches a short link by key from the database and returns a standardized response model, with improved error handling.
    • create_url inserts new short links into the database, ensuring unique keys and returning the created record(s). (src/app/main.py) [1] [2] [3] [4]

API Models and Schema Updates

  • Renamed and updated schema models for clarity and consistency:
    • URLRequestModelNewUrlSubmissionModel
    • UrlResponseModelGetUrlResponseModel
    • Added GetURLRequestModel for key-based retrieval requests.
    • Moved schemas from src/models/schemas.py to src/app/schemas/schemas.py. (src/app/schemas/schemas.py) [1] [2]

Makefile Improvements

  • Enhanced Makefile targets:
    • Updated help text and activation instructions.
    • Improved output messages for precommit checks.
    • Removed Docker-related targets for a more focused developer workflow. (Makefile) [1] [2]

These changes lay the foundation for a more robust, persistent, and maintainable backend, and standardize API interactions for future development.

…schemas; remove legacy code; introducing sqlite db for now during development. will move to dockerized-postgres datastore instance later --@iamserda
#1: introducing a file-based RDMS via SQLite. Current model is extremely basic to get things working quickly. Will add both analytics data-table, and more columns to the current shortilink table.

#2: streamlined database engine creation and improved error handling;

#3L removed unused code and simplified main app initialization

--@iamserda
…equest shorti based on its key, will implement just providing the short url and service redirect request using either 301 or 302 to the new resource permanent url. --@iamserda
@iamserda iamserda merged commit f2adbc6 into main Feb 12, 2026
4 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant